<template>
  <div>
    <v-card style="width:100%;">
      <v-card-title>
        <h3>{{name}}</h3>
      </v-card-title>
    <v-card-text>
      <v-form ref="searchForm">
      <v-layout row wrap>
        <v-flex xs12 sm4 md2 class="pr-3">
          <v-autocomplete :items="env.items" v-model="env.value" item-text="text" item-value="value" label="环境" :clearable="true" autocomplete ></v-autocomplete>
        </v-flex>
        <v-spacer></v-spacer>
        <v-btn color="primary" @click.stop="projectSearch" small><h4>查询</h4></v-btn>
      </v-layout>
      </v-form>
      </v-card-text>
    </v-card>
    <p></p>
      <v-card >
        <v-card-title>
          <v-flex xs12 sm12 md5 class="pr-3">
            <newproject></newproject>
          </v-flex>
          <v-flex xs12 sm12 md7 class="pr-3">
            <v-text-field append-icon="search" :label="searchLabel" single-line hide-details v-model="search" ></v-text-field>
          </v-flex>
            <projectInfo :infoDialog = "infoDialog" :id = "id"></projectInfo>
            <projectSvg :svgDialog = "svgDialog" :id = "id"></projectSvg>
            <editproject :editdialog = "editdialog" :id = "id"></editproject>
        </v-card-title>
          <v-data-table
            :headers="headers"
            :items="items"
            :pagination.sync="pagination"
            :total-items="totalItems"
            :loading="loading"
            :rows-per-page-items="rowsPerPageItems"
            :no-data-text="etext"
            class="elevation-1">
            <template slot="items" slot-scope="props">
              <tree :model="props.item" :colums="tempHeader" ></tree>
            </template>
            <template slot="no-data">
              <v-alert :value="true" color="error" icon="warning">
                {{etext}}
              </v-alert>
            </template>
          </v-data-table>
      </v-card>
  </div>
</template>

<script>
import { createNamespacedHelpers } from 'vuex'
const { mapActions } = createNamespacedHelpers('listproject')

export default {
  name: 'listproject',
  data: function () {
    return this.$store.state.listproject
  },
  watch: {
    pagination () {
      this.handlerProject()
    },
    search () {
      this.handlerProject()
    }
  },
  methods: {
    ...mapActions({
      handlerProject: 'handlerProject',
      loadProjectFilters: 'loadProjectFilters',
      projectSearch: 'projectSearch',
      loadProjectHeaders: 'loadProjectHeaders',
      showSvgTable: 'showSvgTable'
    })
  },
  mounted () {
    this.loadProjectFilters()
    this.loadProjectHeaders()
  },
  components: {
    newproject: () => import('../project/newproject'),
    editproject: () => import('../project/editproject'),
    projectSvg: () => import('../project/projectSvg'),
    projectInfo: () => import('../project/projectinfo'),
    tree: () => import('../../components/tree/tree')
  }
}

</script>
<style scoped>
  .treeBorder {
    border-bottom: 1px solid rgba(0,0,0,.12);
  }
</style>
